﻿using Lu.Blog.Domain.Model.DocumentType;
using umbraco.interfaces;
using umbraco.NodeFactory;
using Vega.USiteBuilder;

namespace Lu.Blog.Domain.Factory.Impl
{
    internal class NodeFactoryImpl : INodeFactory
    {
        public INode GetNode(int nodeId)
        {
            return new Node(nodeId);
        }

        public DocumentTypeBase GetDocumentFromNode(INode node)
        {
            switch (node.NodeTypeAlias)
            {
                case "HomePage":
                    return ContentHelper.GetByNodeId<HomePage>(node.Id);
                case "ContentPage":
                    return ContentHelper.GetByNodeId<ContentPage>(node.Id);
                case "Category":
                    return ContentHelper.GetByNodeId<Category>(node.Id);
                case "Author":
                    return ContentHelper.GetByNodeId<Author>(node.Id);
            }

            return null;
        }


        public DocumentTypeBase GetBaseNavigationFromNode(INode node)
        {
            return GetDocumentFromNode(node) as BaseNavigation;
        }
    }
}
